package com.zzxx.controller;

import com.github.pagehelper.PageInfo;
import com.zzxx.pojo.UserInfo;
import com.zzxx.pojo.UserRole;
import com.zzxx.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/userController")
public class UserController {
    @Autowired
    private UserService userService;
    @RequestMapping("/list")
    @ResponseBody
    public PageInfo<UserInfo> getUsers(@RequestParam(defaultValue = "1") Integer pageNum, @RequestParam(defaultValue = "2") Integer pageSize){
        PageInfo<UserInfo> pageInfo = userService.getAllUsers(pageNum,pageSize);
        return pageInfo;
    }

    @RequestMapping("/getById")
    @ResponseBody
    public UserInfo getById(String id){
        return userService.findById(id);
    }

}
